package com.briup.day05;

import java.util.Arrays;
import java.util.Random;

/**
 * @author 谭梦寻
 * @version 1.1
 * 生成随机验证码
 */
public class Test07 {
    public static void main(String[] args) {
//        创建存放验证码的数组 数组中的元素从data中获取
        char[] validateCode = new char[4];
//        创建存放大小写字母以及数组的数组
        char[] data = new char[62]; // 0-9 26+26
        for (int i = 0; i < data.length; i++) {
            if (i <= 9) { // 0-9
                data[i] = (char) (i + 48);// ASCII '0':49
                System.out.print(data[i] + " ");
            } else if (i > 9 && i <= 35) { //a-z 26+8
                data[i] = (char) (i + 87);// ASCII '0':49 a:97 A:65
//                System.out.print(data[i] + " ");
            } else {//36
                data[i] = (char) (i + 29);// ASCII '0':49 A:97
//                System.out.print(data[i] + " ");
            }

        }
        System.out.println("");
        for (int i = 0; i < data.length; i++) {
            System.out.print(data[i] + " ");
        }
        System.out.println("");
//        给data输出添加元素值
        for (int i = 0; i < 4; i++) {
            Random random = new Random();
            int num = random.nextInt(63) + 0;
            validateCode[i] = data[num];
        }
        //输出验证码
        System.out.println("验证码内容：" + Arrays.toString(validateCode));

    }
}
